home *** CD-ROM | disk | FTP | other *** search
/ CGI How-To / CGI HOW-TO.iso / chap7 / 7_1 / ht71.pl < prev    next >
Encoding:
Perl Script  |  1996-06-15  |  1.3 KB  |  74 lines

  1. #!/usr2/local/bin/perl -w
  2.  
  3. require "cgilib.pl";
  4.  
  5. #
  6. # Configurable Variables
  7. #
  8. $SENDMAIL = '/usr/bin/sendmail';
  9. $TO       = 'kgr';
  10. $SUBJECT  = 'Survey Results';
  11. $BACK     = '<A HREF="/kgr/book">Back to my Homepage</A>';
  12. @FIELDS   = qw(name email street city state zip rating comments);
  13.  
  14. # Output the HTML content type
  15. print "Content-type: text/html\n\n";
  16.  
  17. # Initialize a hash of CGI arguments using
  18. # routines from cgilib.pl
  19. readParse(*dict);
  20.  
  21. # Build the 'from' address of the form:
  22. #     "email address, (real name)"
  23. my $from  = "$dict{email}, ($dict{name})";
  24.  
  25. # The -t causes the To: field to be read from standard input
  26. # instead of being expected on the command line.  The -oi
  27. # prevents a dot on a line by itself from being interpreted
  28. # as a message terminator.
  29. open  MAIL, "|$SENDMAIL -t -oi";
  30.  
  31. # Output the mail header
  32. print MAIL <<EOMH;
  33. Reply-to: $from 
  34. From: $from
  35. To: $TO
  36. Subject: $SUBJECT
  37.  
  38. EOMH
  39.  
  40. # Output the mail body
  41. foreach (@FIELDS)
  42. {
  43.     print MAIL "<", uc($_), ">\n $dict{$_}\n\n";
  44. }
  45.  
  46. # Output the mail footer
  47. print MAIL <<EOMF;
  48.  
  49. <REMOTE HOST>
  50. $ENV{'REMOTE_HOST'}
  51.  
  52. <REMOTE ADDRESS>
  53. $ENV{'REMOTE_ADDR'}
  54.  
  55. <USER AGENT>
  56. $ENV{'HTTP_USER_AGENT'}
  57.  
  58. EOMF
  59.  
  60. # Close the pipe, sending the mail
  61. close MAIL;
  62.  
  63. # Generate HTML notification
  64. print <<EOH;
  65. <HTML><BODY><H1>
  66. Your comments have been noted.<BR>
  67. Thank you for your time.<BR>
  68. <BR>
  69. $BACK
  70. </H1></BODY></HTML>
  71. EOH
  72.  
  73. 1;
  74.